//package com.dhcc.bpm.common.utils;
//
//import java.security.SecureRandom;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//import java.util.Random;
///**
// * @ClassName PasswordGeneratorUtils
// * @Description 随机生成密码
// * @Author xiafayu
// * @Date 2020/2/21 0021 15:16
// * @Version V1.0
// * @Copyright: 2020 东华软件 . All rights reserved.
// **/
//public class PasswordGeneratorUtils {
//    public static final char[] allowedSpecialCharactors = {
//            '`', '~', '@', '#', '$', '%', '^', '&',
//            '*', '(', ')', '-', '_', '=', '+', '[',
//            '{', '}', ']', '\\', '|', ';', ':', '"',
//            '\'', ',', '<', '.', '>', '/', '?'};//密码能包含的特殊字符
//    private static final int letterRange = 26;
//    private static final int numberRange = 10;
//    private static final int spCharactorRange = allowedSpecialCharactors.length;
//    private static final Random random = new SecureRandom();;
//    private static int passwordLength;//密码的长度
//    private static int minVariousType;//密码包含字符的最少种类
//
//    //生成随机密码
//    public PasswordGeneratorUtils(int passwordLength, int minVariousType) {
//        if (minVariousType > CharactorType.values().length) minVariousType = CharactorType.values().length;
//        if (minVariousType > passwordLength) minVariousType = passwordLength;
//        this.passwordLength = passwordLength;
//        this.minVariousType = minVariousType;
//    }
//
//    public static String generateRandomPassword() {
//        char[] password = new char[passwordLength];
//        List<Integer> pwCharsIndex = new ArrayList();
//        for (int i = 0; i < password.length; i++) {
//            pwCharsIndex.add(i);
//        }
//        List<CharactorType> takeTypes = new ArrayList(Arrays.asList(CharactorType.values()));
//        List<CharactorType> fixedTypes = Arrays.asList(CharactorType.values());
//        int typeCount = 0;
//        while (pwCharsIndex.size() > 0) {
//            int pwIndex = pwCharsIndex.remove(random.nextInt(pwCharsIndex.size()));//随机填充一位密码
//            Character c;
//            if (typeCount < minVariousType) {//生成不同种类字符
//                c = generateCharacter(takeTypes.remove(random.nextInt(takeTypes.size())));
//                typeCount++;
//            } else {//随机生成所有种类密码
//                c = generateCharacter(fixedTypes.get(random.nextInt(fixedTypes.size())));
//            }
//            password[pwIndex] = c.charValue();
//        }
//        return String.valueOf(password);
//    }
//
//    private static Character generateCharacter(CharactorType type) {
//        Character c = null;
//        int rand;
//        switch (type) {
//            case LOWERCASE://随机小写字母
//                rand = random.nextInt(letterRange);
//                rand += 97;
//                c = new Character((char) rand);
//                break;
//            case UPPERCASE://随机大写字母
//                rand = random.nextInt(letterRange);
//                rand += 65;
//                c = new Character((char) rand);
//                break;
//            case NUMBER://随机数字
//                rand = random.nextInt(numberRange);
//                rand += 48;
//                c = new Character((char) rand);
//                break;
//            case SPECIAL_CHARACTOR://随机特殊字符
//                rand = random.nextInt(spCharactorRange);
//                c = new Character(allowedSpecialCharactors[rand]);
//                break;
//        }
//        return c;
//    }
//
//   enum CharactorType {
//        LOWERCASE,  //小写字母
//        UPPERCASE,  //大写字母
//        NUMBER,  //数字
//        SPECIAL_CHARACTOR  //特殊字符
//    }
//
//}
//
